GrapeCity MultiRow Windows Forms Documentation
CreateGridTemplate(IEnumerable<Cell>,Int32) Method
Example 


A Cell collection that is filled based on the standard template matrix.
A System.Int32 that indicates the maximum column width.
Creates a standard Template matrix with the specified cells.
Syntax
Public Overloads Shared Function CreateGridTemplate( _
   ByVal cells As IEnumerable(Of Cell), _
   ByVal columnsMaxWidth As Integer _
) As Template
Dim cells As IEnumerable(Of Cell)
Dim columnsMaxWidth As Integer
Dim value As Template
 
value = Template.CreateGridTemplate(cells, columnsMaxWidth)
public static Template CreateGridTemplate( 
   IEnumerable<Cell> cells,
   int columnsMaxWidth
)

Parameters

cells
A Cell collection that is filled based on the standard template matrix.
columnsMaxWidth
A System.Int32 that indicates the maximum column width.

Return Value

A Template that represents a standard Template matrix.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThe cells parameter is a null reference (Nothing in Visual Basic).
System.ArgumentOutOfRangeExceptionThe columnsMaxWidth is less than or equal to 0.
System.ArgumentException

There exists one cell in cells that is a null reference (Nothing in Visual Basic).

-or-

There exists one cell in cells that has been added to another Section or Template.

-or-

There are no cells in cells.

System.InvalidOperationExceptionThere exists one cell in cells that cannot be added to the Row section.
Remarks
This method is based on the CreateGridTemplate(IEnumerable<Cell>) method. If the sum of all arranged cell widths is greater than columnsMaxWidth, the cells that do not fit in the first line are moved to the next line.
Example
The following code example shows how to use this method to create a grid template. This code example is part of a larger example provided for the CreateGridTemplate(int) class.
void SetFourth_Click(object sender, EventArgs e)
        {
            NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell();
            numericUpDownCell1.Value = 0;

            NumericUpDownCell numericUpDownCell2 = new NumericUpDownCell();
            numericUpDownCell2.Value = 16m;

            Template template1 = Template.CreateGridTemplate(new Cell[] { numericUpDownCell1, numericUpDownCell2 }, Int32.MaxValue,
                AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber, 50);
            template1.ColumnHeaders[0].Cells[0].Value = "Column1";
            template1.ColumnHeaders[0].Cells[1].Value = "Column2";

            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 10;
        }
Private Sub SetFourth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFourth.Click
        Dim numericUpDownCell1 As New NumericUpDownCell()
        numericUpDownCell1.Value = 0

        Dim numericUpDownCell2 As New NumericUpDownCell()
        numericUpDownCell2.Value = 16D

        Dim template1 As Template = Template.CreateGridTemplate(New Cell() {numericUpDownCell1, numericUpDownCell2}, Int32.MaxValue, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber, 50)
        template1.ColumnHeaders(0).Cells(0).Value = "Column1"
        template1.ColumnHeaders(0).Cells(1).Value = "Column2"

        gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 10
    End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Template Class
Template Members
Overload List
CreateGridTemplate(Int32) Method
CreateGridTemplate(Int32,Int32,Int32) Method
CreateGridTemplate(Int32,Int32,Int32,Int32) Method
CreateGridTemplate(Int32,Int32,Int32,Int32,AutoGenerateGridTemplateStyles) Method
CreateGridTemplate(Int32,Int32,Int32,Int32,AutoGenerateGridTemplateStyles,Int32) Method
CreateGridTemplate(IEnumerable<Cell>) Method
CreateGridTemplate(IEnumerable<Cell>,Int32,AutoGenerateGridTemplateStyles) Method
CreateGridTemplate(IEnumerable<Cell>,Int32,AutoGenerateGridTemplateStyles,Int32) Method

 

 


Copyright © GrapeCity, inc. All rights reserved.